import gevent
from gevent.subprocess import PIPE, Popen


def cron_job(n):
    while True:
        print("cron_job is running")
        gevent.sleep(n)


g1 = gevent.spawn(cron_job, 0.1)
sub = Popen(['sleep 0.3; uptime'], stdout=PIPE, shell=True)
out, err = sub.communicate()
g1.kill()
print(out.rstrip())
